package net.brucecooper.mindmap.client;

import gwt.canvas.client.Image;
import gwt.canvas.client.Canvas;

public class ImageComponent extends SimpleComponent {
	Image image;
	
	public ImageComponent(String icon) {
		this.image = IconManager.getCanvasImage(icon);
	}
	
	@Override
	public int getPreferredWidth(Canvas canvas) {
		return image.getWidth();
	}
	
	@Override
	public int getPreferredHeight(Canvas canvas) {
		return image.getHeight();
	}
	
	@Override
    public void paintComponent(Canvas ctx, Clip clip) {
		ctx.drawImage(image, 0,0);
	}
}
